<?php
/*
+--------------------------------------------------------------------------
|   AffiliStore 2
|   ========================================
|   Web: http://www.affilistore.com
|   Email: admin (at) affilistore (dot) com
|	License Type: AffiliStore 2 is NOT open source software and limitations apply 
|   Licence Info: Visit AffiliStore website and click on 'Licence'
+--------------------------------------------------------------------------
*/
// checks to see if password session is set
// if not redirects to ../admin/
if($_SESSION['loggedIn'] == 0 && !isset($adminPage)){
include('../includes/auth.inc.php');
}











// update options
if (isset($_POST['od_updated'])) {

	// check to see if details have been completed
	if (empty($_POST['pOther']) || empty($_POST['pColumns']) || empty($_POST['pNews']) || empty($_POST['pCompare']) || empty($_POST['pSimilar'])) {
	$error = 1;

	// else change details
	} else {

	
	// update nav options
	$sql =  sprintf("UPDATE affiliSt_config SET value = %s WHERE name = 'navOptions'",
			   quote_smart($_POST['showProducts'].':'.$_POST['showCustom'].':'.$_POST['showFeatured'].':'.$_POST['showPopular'].':'.$_POST['showRecip'].':'.$_POST['showPages'].':'.$_POST['showNews'].':'.$_POST['htmlPerma'].':'.$_POST['showTags'].':'.$_POST['htmlpermawords'].':'.$_POST['showCompare'].':'.$_POST['showSimilar'].':'.$_POST['merchantProdIDs'].':'.$_POST['showComments'].':'.$_POST['showProductsSub'].':'.$_POST['useCache'].':'.$_POST['showHistory']));
	mysql_query($sql, $databaseConnect) or die(mysql_error());
	
	
	// update prods per page options
	$sql =  sprintf("UPDATE affiliSt_config SET value = %s WHERE name = 'prodPerPage'",
			   quote_smart('1:'.$_POST['pOther'].':'.$_POST['pColumns'].':'.$_POST['pNews'].':'.$_POST['pCompare'].':'.$_POST['pSimilar']));
	mysql_query($sql, $databaseConnect) or die(mysql_error());

	
	// update product listings options
	$sql =  sprintf("UPDATE affiliSt_config SET value = %s WHERE name = 'prodListings'",
			   quote_smart($_POST['showPMT'].':'.$_POST['showPMPID'].':'.$_POST['showPPC'].':'.$_POST['showPPB'].':'.$_POST['showPPPT'].':'.$_POST['showPPD'].':'.$_POST['showPPP'].':'.$_POST['showPEFA'].':'.$_POST['showPEFB'].':'.$_POST['showPEFC'].':'.$_POST['showPEFD'].':'.$_POST['showPEFE'].':'.$_POST['showPTitles'].':'.$_POST['showPMerchantLogo']));
	mysql_query($sql, $databaseConnect) or die(mysql_error());

	
	// update product listings options
	$sql =  sprintf("UPDATE affiliSt_config SET value = %s WHERE name = 'prodSingle'",
			   quote_smart($_POST['showSMT'].':'.$_POST['showSMPID'].':'.$_POST['showSPC'].':'.$_POST['showSPB'].':'.$_POST['showSPPT'].':'.$_POST['showSPD'].':'.$_POST['showSPP'].':'.$_POST['showSEFA'].':'.$_POST['showSEFB'].':'.$_POST['showSEFC'].':'.$_POST['showSEFD'].':'.$_POST['showSEFE'].':'.$_POST['showSTitles'].':'.$_POST['showSMerchantLogo']));
	mysql_query($sql, $databaseConnect) or die(mysql_error());
	
	}
		
}











// Generate Sitemap XML
if (isset($_GET['sitemap'])) {

$getConfig = mysql_query("SELECT * FROM affiliSt_config WHERE name = 'installDir'");
$configLink = mysql_fetch_assoc($getConfig);

// get navigation options
$getNavOpt = mysql_query("SELECT * FROM affiliSt_config WHERE name = 'navOptions'");
$navOpt = mysql_fetch_assoc($getNavOpt);
$navOpt = explode(":", $navOpt['value']);


// write to xml file
$file= fopen("../sitemap.xml", "w");

$_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";


$_xml .="<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\r\n";

// home page
$_xml .="<url>\r\n";
$_xml .="<loc>".$configLink['value']."</loc>\r\n";
$_xml .="<changefreq>daily</changefreq>\r\n";
$_xml .="<priority>1.0</priority>\r\n";
$_xml .="</url>\r\n";

// news
if ($navOpt[6] == 1) {

$_xml .="<url>\r\n";
	if ($navOpt[7] == 1) {
	// html perma
	$_xml .="<loc>".$configLink['value']."news/home.html</loc>\r\n";
	} else {
	// php link
	$_xml .="<loc>".$configLink['value']."index.php?case=news&npag=home</loc>\r\n";
	}
$_xml .="</url>\r\n";
// repeat news listings
$getNews = mysql_query("SELECT * FROM affiliSt_news ORDER BY timestamp,id DESC");
$news = mysql_fetch_assoc($getNews);
	do { 
		if ($news['id'] !== NULL) {
		$_xml .="<url>\r\n";
			if ($navOpt[7] == 1) {
			// html perma
			$_xml .="<loc>".$configLink['value']."newsitem/".$news['id'].'/'.urltxt($news['name']).".html</loc>\r\n";
			} else {
			// php link
			$_xml .="<loc>".$configLink['value']."index.php?case=newsitem&npag=".$news['id']."</loc>\r\n";
			}
		$_xml .="</url>\r\n";
		}
	} while ($news = mysql_fetch_assoc($getNews));

}

// pages
if ($navOpt[5] == 1) {

$getPages = mysql_query("SELECT * FROM affiliSt_pages ORDER BY id ASC");
$pages = mysql_fetch_assoc($getPages);
	do { 
		if ($pages['id'] !== NULL && $pages['id'] != 1 &&  $pages['parent'] == 0) {
		$_xml .="<url>\r\n";
			if ($navOpt[7] == 1) {
			// html perma
			$_xml .="<loc>".$configLink['value']."page/".$pages['id'].'/'.urltxt($pages['name']).".html</loc>\r\n";
			} else {
			// php link
			$_xml .="<loc>".$configLink['value']."index.php?case=page&page=".$pages['id']."</loc>\r\n";
			}
		$_xml .="</url>\r\n";
		} else if ($pages['id'] !== NULL && $pages['id'] != 1 &&  $pages['parent'] != 0) {
		$_xml .="<url>\r\n";
			if ($navOpt[7] == 1) {
			// html perma
			$_xml .="<loc>".$configLink['value']."subpage/".$pages['parent']."/".$pages['id'].'/'.urltxt($pages['name']).".html</loc>\r\n";
			} else {
			// php link
			$_xml .="<loc>".$configLink['value']."index.php?case=subpage&page=".$pages['parent']."&amp;subpage=".$pages['id']."</loc>\r\n";
			}
		$_xml .="</url>\r\n";
		}
	} while ($pages = mysql_fetch_assoc($getPages));

}

// built categories
if ($navOpt[1] == 1) {
	
$getBuiltCategories = mysql_query("SELECT * FROM affiliSt_categories ORDER BY id ASC");
$builtCategories = mysql_fetch_assoc($getBuiltCategories);
	do { 
		if ($builtCategories['id'] !== NULL && $builtCategories['parent'] == 0) {
		$_xml .="<url>\r\n";
			if ($navOpt[7] == 1) {
			// html perma
			$_xml .="<loc>".$configLink['value']."categories/".$builtCategories['id']."/".urltxt($builtCategories['name']).".html</loc>\r\n";
			} else {
			// php link
			$_xml .="<loc>".$configLink['value']."index.php?case=categories&nc=".$builtCategories['id']."</loc>\r\n";
			}
		$_xml .="</url>\r\n";
		} else if ($builtCategories['id'] !== NULL &&  $builtCategories['parent'] != 0) {
		$_xml .="<url>\r\n";
			if ($navOpt[7] == 1) {
			$getParentCategory = mysql_query("SELECT * FROM affiliSt_categories WHERE id=".$builtCategories['parent']);
			$parentCategory = mysql_fetch_assoc($getParentCategory);
			// html perma
			$_xml .="<loc>".$configLink['value']."subcategories/".$builtCategories['parent']."/".$builtCategories['id']."/".urltxt($parentCategory['name'])."/".urltxt($builtCategories['name']).".html</loc>\r\n";
			} else {
			// php link
			$_xml .="<loc>".$configLink['value']."index.php?case=subcategories&nc=".$builtCategories['parent']."&amp;nb=".$builtCategories['id']."</loc>\r\n";
			}
		$_xml .="</url>\r\n";
		}
	} while ($builtCategories = mysql_fetch_assoc($getBuiltCategories));

}

// links
if ($navOpt[4] == 1) {

$_xml .="<url>\r\n";
	if ($navOpt[7] == 1) {
	// html perma
	$_xml .="<loc>".$configLink['value']."links/1.html</loc>\r\n";
	} else {
	// php link
	$_xml .="<loc>".$configLink['value']."index.php?case=links&ld=1</loc>\r\n";
	}
$_xml .="</url>\r\n";

$getLinks = mysql_query("SELECT * FROM affiliSt_linkcategories ORDER BY id ASC");
$links = mysql_fetch_assoc($getLinks);
	do { 
		if ($links['id'] !== NULL) {
		$_xml .="<url>\r\n";
			if ($navOpt[7] == 1) {
			// html perma
			$_xml .="<loc>".$configLink['value']."links/1/".$links['id'].".html</loc>\r\n";
			} else {
			// php link
			$_xml .="<loc>".$configLink['value']."index.php?case=links&ld=1&amp;cat=".$links['id']."</loc>\r\n";
			}
		$_xml .="</url>\r\n";
		}
	} while ($links = mysql_fetch_assoc($getLinks));

}


// generated categories
if ($navOpt[0] == 1) {

$getGenCategories = mysql_query("SELECT * FROM affiliSt_products1 ORDER BY prodCategory ASC");
$genCategories = mysql_fetch_assoc($getGenCategories);
	do { 
		$catresult = ucwords(strtolower($genCategories['prodCategory']));
		if ($storedCategory != $catresult && $catresult != NULL) {
		$_xml .="<url>\r\n";
			if ($navOpt[7] == 1) {
			// html perma
			$_xml .="<loc>".$configLink['value']."products/".str_replace(" ", "-", $catresult).".html</loc>\r\n";
			} else {
			// php link
			$_xml .="<loc>".$configLink['value']."index.php?case=products&pc=".str_replace(" ", "+", $catresult)."</loc>\r\n";
			}
		$_xml .="</url>\r\n";
		
			// generated brands
			$getGenBrands = mysql_query("SELECT * FROM affiliSt_products1 WHERE prodCategory = '$catresult' ORDER BY prodBrand ASC");
			$genBrand = mysql_fetch_assoc($getGenBrands);
			do {
			$theresult = ucwords(strtolower($genBrand['prodBrand']));
				if ($storedBrand != $theresult && $theresult != NULL) {
				$_xml .="<url>\r\n";
					if ($navOpt[7] == 1) {
					// html perma
					$_xml .="<loc>".$configLink['value']."subproducts/".str_replace(" ", "-", $catresult)."/".str_replace(" ", "-", $theresult).".html</loc>\r\n";
					} else {
					// php link
					$_xml .="<loc>".$configLink['value']."index.php?case=subproducts&pc=".str_replace(" ", "+", $catresult)."&amp;pb=".str_replace(" ", "+", $theresult)."</loc>\r\n";
					}
				$_xml .="</url>\r\n";
				$storedBrand = $theresult;
				} else {
				$theresult = ucwords(strtolower($genBrand['prodBrand']));
				}
			} while ($genBrand = mysql_fetch_assoc($getGenBrands));
			// end generated brands
			
		$storedCategory = $catresult;
		} else {
		$catresult = ucwords(strtolower($genCategories['prodCategory']));
		}
	} while ($genCategories = mysql_fetch_assoc($getGenCategories));
}
	
// product pages
$getProds = mysql_query("SELECT * FROM affiliSt_products1 ORDER BY prodDB ASC, prodID ASC");
$prods = mysql_fetch_assoc($getProds);
do { 
	if ($prods['prodID'] !== NULL) {
	$_xml .="<url>\r\n";
					
		// use merchant product ids
		if ($navOpt[12] == 1) {
		$theprodID = $prods['merchantProdID'];
		} else {
		$theprodID = $prods['dbProdID'];
		}
					
		if ($navOpt[7] == 1) {
		// html perma
		$_xml .="<loc>".$configLink['value']."product/".$prods['prodDB'].'/'.$theprodID.'/'.urltxt($prods['prodName']).".html</loc>\r\n";
		} else {
		// php link
		$_xml .="<loc>".$configLink['value']."index.php?case=product&proddb=".$prods['prodDB']."&amp;pid=".$theprodID."</loc>\r\n";
		}
	$_xml .="</url>\r\n";
	}
} while ($prods = mysql_fetch_assoc($getProds));




$_xml .="</urlset>\r\n";

fwrite($file, $_xml);
fclose($file);

}



// clear cache
if (isset($_GET['clearcache'])) {
$cachedir = '../cache/';

	if ($handle = @opendir($cachedir)) {
		while (false !== ($file = @readdir($handle))) {
			if ($file != '.' and $file != '..') {
			@unlink($cachedir . '/' . $file);
			}
		}
	@closedir($handle);
	}
}










$getUserDetails = mysql_query("SELECT * FROM affiliSt_config");
$userDetails = mysql_fetch_assoc($getUserDetails);
?>






<?php
// error report
if ($error == 1) {
echo '<fieldset><strong style="color:red">ERROR: Fields must not be empty</strong></fieldset>';
} else {
	// category added report
	if (isset($_POST['od_updated'])) {
	echo '<fieldset><strong style="color:green">General Settings Updated</strong></fieldset>';
	}
	// sitemap complete message
	if ($_GET['sitemap'] == 1) {
	echo "<fieldset><strong style=\"color:green\">Sitemap XML has been written.</strong>  <a href=\"../sitemap.xml\" target=\"_blank\">View the sitemap XML.</a></fieldset>";
	}
	// sitemap complete message
	if ($_GET['clearcache'] == 1) {
	echo "<fieldset><strong style=\"color:green\">The cache folder has been cleared</strong></fieldset>";
	}
	// show .htaccess if $htmlPermaMem was 0
	if ($_POST['htmlPermaMem'] == 0 && $_POST['htmlPerma'] == 1) {
	$basedir = str_replace("admin/index.php", "", $_SERVER['PHP_SELF']);
	echo '<fieldset><strong style="color:red">You need to create a <span style="color:green">.htaccess</span> file in your install directory (<span style="color:green">'.$installDir['value'].'</span>) and add the following code:</strong><br />';
	echo '<textarea name="htaccess" cols="80" rows="4">#start .htaccess code
RewriteEngine On
RewriteBase '.$basedir.'


#Rewrite image paths to look like jpgs
RewriteRule ^img/([^/]+)/([^/]+)\.jpg$ imgsrc.php?proddb=$1&img=$2 [L]
RewriteRule ^img/([^/]+)/([^/]+)/([^/]+)\.jpg$ imgsrc.php?&proddb=$1&img=$2&single=$3 [L]

RewriteRule ^product/([^/]+)/([^/]+)/([^/]+)\.html$ index.php?case=product&proddb=$1&pid=$2&urltxt=$3 [L]
RewriteRule ^saveproduct/([^/]+)/([^/]+)/([^/]+)\.html$ index.php?case=product&proddb=$1&pid=$2&urltxt=$3&savelink=true [L]
RewriteRule ^products/([^/]+)\.html$ index.php?case=products&pc=$1 [L]
RewriteRule ^subproducts/([^/]+)/([^/]+)\.html$ index.php?case=subproducts&pc=$1&pb=$2 [L]
RewriteRule ^productspage/([^/]+)/([^/]+)\.html$ index.php?pageNum_product=$1&case=products&pc=$2 [L]
RewriteRule ^subproductspage/([^/]+)/([^/]+)/([^/]+)\.html$ index.php?pageNum_product=$1&case=subproducts&pc=$2&pb=$3 [L]
RewriteRule ^categories/([^/]+)/([^/]+)\.html$ index.php?case=categories&nc=$1&urltxt=$2 [L]
RewriteRule ^subcategories/([^/]+)/([^/]+)/([^/]+)/([^/]+)\.html$ index.php?case=subcategories&nc=$1&nb=$2&urltxt=$3&suburltxt=$4 [L]
RewriteRule ^categoriespage/([^/]+)/([^/]+)/([^/]+)\.html$ index.php?pageNum_product=$1&case=categories&nc=$2&urltxt=$3 [L]
RewriteRule ^subcategoriespage/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)\.html$ index.php?pageNum_product=$1&case=subcategories&nc=$2&nb=$3&urltxt=$4&suburltxt=$5 [L]
RewriteRule ^news/([^/]+)\.html$ index.php?case=news&npag=$1 [L]
RewriteRule ^news/([^/]+)/([^/]+)\.html$ index.php?case=news&npag=$2&npage=$1 [L]
RewriteRule ^newsitem/([^/]+)/([^/]+)\.html$ index.php?case=newsitem&npag=$1&urltxt=$2 [L]
RewriteRule ^links/([^/]+)\.html$ index.php?case=links&ld=$1 [L]
RewriteRule ^linksh/([^/]+)/([^/]+)\.html$ index.php?case=links&ld=$2&lpage=$1 [L]
RewriteRule ^links/([^/]+)/([^/]+)\.html$ index.php?case=links&ld=$1&cat=$2 [L]
RewriteRule ^links/([^/]+)/([^/]+)/([^/]+)\.html$ index.php?case=links&ld=$2&cat=$3&lpage=$1 [L]
RewriteRule ^page/([^/]+)/([^/]+)\.html$ index.php?case=page&page=$1&urltxt=$2 [L]
RewriteRule ^subpage/([^/]+)/([^/]+)/([^/]+)\.html$ index.php?case=subpage&page=$1&subpage=$2&urltxt=$3 [L]
RewriteRule ^stores/([^/]+)\.html$ index.php?case=stores&merchant=$1 [L]</textarea></fieldset>';
	}
}
?>





<form action="index.php?ad=od" method="post" name="showOptions">



<?php do { ?>




<?php if ($userDetails['name'] == 'navOptions') {

$navOptions = explode(":", $userDetails['value']);
?>
<fieldset>
<legend>Navigation Settings</legend>
<input name="showProducts" id="show_prod" type="checkbox" value="1" <?php if ($navOptions[0] == 1) { echo 'checked="checked"'; } ?> /> 
<label for="show_prod">Show Products Navigation</label><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="showProductsSub" id="show_prod_sub" type="checkbox" value="1" <?php if ($navOptions[14] == 1) { echo 'checked="checked"'; } ?> /> 
<label for="show_prod_sub">Display Products Random Sub-Links</label><br />
<input name="showCustom" id="show_cust" type="checkbox" value="1" <?php if ($navOptions[1] == 1) { echo 'checked="checked"'; } ?> /> 
<label for="show_cust">Show Custom Navigation</label><br />
<input name="showFeatured" id="show_feat" type="checkbox" value="1" <?php if ($navOptions[2] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_feat">Show Featured Product</label><br />
<input name="showPopular" id="show_pop" type="checkbox" value="1" <?php if ($navOptions[3] == 1) { echo 'checked="checked"'; } ?> /> <label for="show_pop">Show Popular Products</label><br />
<input name="showRecip" id="show_recip" type="checkbox" value="1" <?php if ($navOptions[4] == 1) { echo 'checked="checked"'; } ?> /> 
<label for="show_recip">Show Reciprocal Links Directory</label><br />
<input name="showPages" id="show_pages" type="checkbox" value="1" <?php if ($navOptions[5] == 1) { echo 'checked="checked"'; } ?> /> 
<label for="show_pages">Show Page Links</label><br />
<input name="showNews" id="show_news" type="checkbox" value="1" <?php if ($navOptions[6] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_news">Show News Items</label><br />
<input name="htmlPerma" id="html_perma" type="checkbox" value="1" <?php if ($navOptions[7] == 1) { echo 'checked="checked"'; } ?> />
<?php if ($navOptions[7] == 0) { ?> 
<input type="hidden" name="htmlpermawords" value="99999" />
<?php  } ?>
<label for="html_perma">Use HTML URLs</label>
<input type="hidden" name="htmlPermaMem" value="<?php echo $navOptions[7] ?>" />
<?php if ($navOptions[7] == 1) { ?>
<label for="html_perma_words">- Word Limit for URL:</label>
<select name="htmlpermawords" id="html_perma_words">
	<option value="99999" <?php if ($navOptions[9] == 99999) { echo 'selected="selected"'; } ?> >Unlimited Words</option>
	<option value="1" <?php if ($navOptions[9] == 1) { echo 'selected="selected"'; } ?> >1 Word</option>
	<option value="2" <?php if ($navOptions[9] == 2) { echo 'selected="selected"'; } ?> >2 Words</option>
	<option value="3" <?php if ($navOptions[9] == 3) { echo 'selected="selected"'; } ?> >3 Words</option>
	<option value="4" <?php if ($navOptions[9] == 4) { echo 'selected="selected"'; } ?> >4 Words</option>
	<option value="5" <?php if ($navOptions[9] == 5) { echo 'selected="selected"'; } ?> >5 Words</option>
</select>
<?php } ?><br />
<input name="merchantProdIDs" id="merchant_prodids" type="checkbox" value="1" <?php if ($navOptions[12] == 1) { echo 'checked="checked"'; } ?> />
<label for="merchant_prodids">Use Merchant Product IDs in URLs</label><br />
<input name="showTags" id="show_tags" type="checkbox" value="1" <?php if ($navOptions[8] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_tags">Show Search Tags</label><br />
<input name="showCompare" id="show_compare" type="checkbox" value="1" <?php if ($navOptions[10] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_compare">Show Compare Products</label><br />
<input name="showSimilar" id="show_similar" type="checkbox" value="1" <?php if ($navOptions[11] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_similar">Show Similar Products</label><br />
<input name="showComments" id="show_comments" type="checkbox" value="1" <?php if ($navOptions[13] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_comments">Show Comments</label><br />
<input name="showHistory" id="show_history" type="checkbox" value="1" <?php if ($navOptions[16] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_history">Show User History</label><br />
<input name="useCache" id="use_cache" type="checkbox" value="1" <?php if ($navOptions[15] == 1) { echo 'checked="checked"'; } ?> />
<label for="use_cache">Use Cache</label>
<?php if ($navOptions[15] == 1) { ?>
<?php 
// check to see if cache folder is writable
$filename = '../cache/';
if (!is_writable($filename)) { ?>
   - Please change the file permissions to <strong>777</strong> for the following folder: <strong>cache/</strong>, this will allow AffiliStore to create the cached files.
<?php } else { ?>
 - <a href="index.php?ad=od&clearcache=1">Clear Cache</a>
<?php }  } ?>
<br />
</fieldset>
<?php } ?>










<?php if ($userDetails['name'] == 'prodPerPage') { 

$prodOptions = explode(":", $userDetails['value']);
?>
<fieldset>
<legend>Product Display Settings</legend>
<table cellpadding="4" cellspacing="0" border="0">
<!-- <tr>
<td>
<label for="prod_home">Number of Products on Home Page:</label>
</td>
<td>
<input name="pHome" type="text" id="prod_home" value="<?php echo $prodOptions[0];?>" />
</td>
</tr> -->
<tr>
<td>
<label for="prod_other">Number of Products on Pages:</label>
</td>
<td>
<input name="pOther" type="text" id="prod_other" value="<?php echo $prodOptions[1];?>" />
</td>
</tr>
<tr>
<td>
<label for="prod_columns">Number of Product Columns:</label>
</td>
<td>
<input name="pColumns" type="text" id="prod_columns" value="<?php echo $prodOptions[2];?>" /> (Adding more columns may require design changes)
</td>
</tr>
<tr>
<td>
<label for="news_items">Number of News Items Per Page:</label>
</td>
<td>
<input name="pNews" type="text" id="news_items" value="<?php echo $prodOptions[3];?>" />
</td>
</tr>
<tr>
<td>
<label for="num_compare">Number of Compare Products:</label>
</td>
<td>
<input name="pCompare" type="text" id="num_compare" value="<?php echo $prodOptions[4];?>" />
</td>
</tr>
<tr>
<td>
<label for="num_similar">Number of Similar Products:</label>
</td>
<td>
<input name="pSimilar" type="text" id="num_similar" value="<?php echo $prodOptions[5];?>" />
</td>
</tr>
</table>
</fieldset>
<?php } ?>







<?php if ($userDetails['name'] == 'prodListings') {

$prodOptions = explode(":", $userDetails['value']);
?>
<fieldset>
<legend>Product Listings Options</legend>
<input name="showPMT" id="show_pmt" type="checkbox" value="1" <?php if ($prodOptions[0] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_pmt">Show Merchant Title</label><br />
<input name="showPMPID" id="show_pmpid" type="checkbox" value="1" <?php if ($prodOptions[1] == 1) { echo 'checked="checked"'; } ?> /> 
<label for="show_pmpid">Show Merchant Product ID</label><br />
<input name="showPPC" id="show_ppc" type="checkbox" value="1" <?php if ($prodOptions[2] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_ppc">Show Product Category</label><br />
<input name="showPPB" id="show_ppb" type="checkbox" value="1" <?php if ($prodOptions[3] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_ppb">Show Product Brand</label><br />
<input name="showPPPT" id="show_pppt" type="checkbox" value="1" <?php if ($prodOptions[4] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_pppt">Show Product Promotional Text</label><br />
<input name="showPPD" id="show_ppd" type="checkbox" value="1" <?php if ($prodOptions[5] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_ppd">Show Product Description</label><br />
<input name="showPPP" id="show_ppp" type="checkbox" value="1" <?php if ($prodOptions[6] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_ppp">Show Product Price</label><br />
<input name="showPEFA" id="show_pefa" type="checkbox" value="1" <?php if ($prodOptions[7] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_pefa">Show Extra Field A</label><br />
<input name="showPEFB" id="show_pefb" type="checkbox" value="1" <?php if ($prodOptions[8] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_pefb">Show Extra Field B</label><br />
<input name="showPEFC" id="show_pefc" type="checkbox" value="1" <?php if ($prodOptions[9] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_pefc">Show Extra Field C</label><br />
<input name="showPEFD" id="show_pefd" type="checkbox" value="1" <?php if ($prodOptions[10] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_pefd">Show Extra Field D</label><br />
<input name="showPEFE" id="show_pefe" type="checkbox" value="1" <?php if ($prodOptions[11] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_pefe">Show Extra Field E</label><br />
<input name="showPTitles" id="show_ptitles" type="checkbox" value="1" <?php if ($prodOptions[12] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_ptitles">Show Titles</label><br />
<input name="showPMerchantLogo" id="show_pmerchantlogo" type="checkbox" value="1" <?php if ($prodOptions[13] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_pmerchantlogo">Show Merchant Logo</label><br />
</fieldset>
<?php } ?>







<?php if ($userDetails['name'] == 'prodSingle') {

$prodOptions = explode(":", $userDetails['value']);
?>
<fieldset>
<legend>Individual Product Listing Options</legend>
<input name="showSMT" id="show_smt" type="checkbox" value="1" <?php if ($prodOptions[0] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_smt">Show Merchant Title</label><br />
<input name="showSMPID" id="show_smpid" type="checkbox" value="1" <?php if ($prodOptions[1] == 1) { echo 'checked="checked"'; } ?> /> 
<label for="show_smpid">Show Merchant Product ID</label><br />
<input name="showSPC" id="show_spc" type="checkbox" value="1" <?php if ($prodOptions[2] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_spc">Show Product Category</label><br />
<input name="showSPB" id="show_spb" type="checkbox" value="1" <?php if ($prodOptions[3] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_spb">Show Product Brand</label><br />
<input name="showSPPT" id="show_sppt" type="checkbox" value="1" <?php if ($prodOptions[4] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_sppt">Show Product Promotional Text</label><br />
<input name="showSPD" id="show_spd" type="checkbox" value="1" <?php if ($prodOptions[5] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_spd">Show Product Description</label><br />
<input name="showSPP" id="show_spp" type="checkbox" value="1" <?php if ($prodOptions[6] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_spp">Show Product Price</label><br />
<input name="showSEFA" id="show_sefa" type="checkbox" value="1" <?php if ($prodOptions[7] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_sefa">Show Extra Field A</label><br />
<input name="showSEFB" id="show_sefb" type="checkbox" value="1" <?php if ($prodOptions[8] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_sefb">Show Extra Field B</label><br />
<input name="showSEFC" id="show_sefc" type="checkbox" value="1" <?php if ($prodOptions[9] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_sefc">Show Extra Field C</label><br />
<input name="showSEFD" id="show_sefd" type="checkbox" value="1" <?php if ($prodOptions[10] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_sefd">Show Extra Field D</label><br />
<input name="showSEFE" id="show_sefe" type="checkbox" value="1" <?php if ($prodOptions[11] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_sefe">Show Extra Field E</label><br />
<input name="showSTitles" id="show_stitles" type="checkbox" value="1" <?php if ($prodOptions[12] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_stitles">Show Titles</label><br />
<input name="showSMerchantLogo" id="show_smerchantlogo" type="checkbox" value="1" <?php if ($prodOptions[13] == 1) { echo 'checked="checked"'; } ?> />
<label for="show_smerchantlogo">Show Merchant Logo</label><br />
</fieldset>
<?php } ?>






<?php } while ($userDetails = mysql_fetch_assoc($getUserDetails)); ?>



<fieldset>
<legend>Sitemap XML</legend>
<?php 
// check to see if sitemap.xml is writable
$filename = '../sitemap.xml';
if (!is_writable($filename)) {
   echo('<p>Please change the file permissions to <strong>777</strong> for the following file: <strong>sitemap.xml</strong></p>
   <p>This will allow AffiliStore to generate the sitemap XML.</p>');
} else {
?>
<img src="images/arrow2.gif" width="9" height="9" alt="" />&nbsp;<a href="index.php?ad=od&sitemap=1">Generate Sitemap XML</a><br />
<?php } ?>
</fieldset>


<fieldset>
<input type="hidden" name="od_updated" value="yes" />
<input value="Update General Settings" type="submit" class="padSubmit" />
</fieldset>
</form>
